package wrs.hcs.tc;

import wrs.hcs.functions.*;

import org.openqa.selenium.WebDriver;

public class WebApp_PairPIN {

	public static WebDriver driver;
	public static String lName1, lName2;
	public static String pin1, pin2;
	
	public void transact() throws Exception
	{
		Webdriver d = new Webdriver();
		Login log = new Login();
		Logout out = new Logout();
		driver = d.startUp();
		
		//Criteria for login in hcs: "admission", "nursing", "billing"
		log.hcs(driver, "admission"); 										//login
		Hcs_NewPatient newPatient = new Hcs_NewPatient();					//new patient in hcs
		
		String patient1 = newPatient.createPatient(driver, "adult");		//new patient in hcs
		out.hcs(driver); 													//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME - Patient1
		String[] arrString = patient1.split(",");
		lName1 = arrString[0];
		pin1 = arrString[1];
		
		log.hcs(driver, "admission"); 										//login
		String patient2 = newPatient.createPatient(driver, "adult");		//new patient in hcs
		out.hcs(driver); 													//logout after getting pin and lastname
		
		//Split string for PIN and LASTNAME - Patient2
		String[] arrsString = patient2.split(",");
		lName2 = arrsString[0];
		pin2 = arrsString[1];
		
		WebApp_Pair p = new WebApp_Pair();
		p.wellness(driver, pin1, pin2, lName1, lName2, false);
		
		driver = d.startUp();
		log.admin(driver); 													//login
		AdminConsole_Pair pconsole = new AdminConsole_Pair();
		pconsole.admin(driver, pin1);   									//update on admin and forward to hcs
		out.admin(driver);

		log.hcs(driver, "nursing");
		Hcs_Nursing pack = new Hcs_Nursing();
		pack.validate(driver, pin1); 										//validate package of patient1
		pack.discharge(driver, pin1); 										//fill up discharge instructions
		pack.pf(driver, pin1); 												//assign pf and discharge
		
		pack.validate(driver, pin2); 										//validate package of patient2
		pack.discharge(driver, pin2); 										//fill up discharge instructions
		pack.pf(driver, pin2); 												//assign pf and discharge
		out.hcs(driver);
		
		//driver = d.startUp();
		log.hcs(driver, "billing"); 						
		Hcs_Billing bill = new Hcs_Billing();
		bill.das(driver, pin1); 											//das discharge patient1
		out.hcs(driver);
		log.hcs(driver, "billing"); 
		bill.das(driver, pin2); 											//das discharge patient2
		out.hcs(driver);
				
		log.hcs(driver, "nursing"); 										//print gatepass
		pack.gatepass(driver, pin1);
		out.hcs(driver);
		
		log.hcs(driver, "nursing"); 										//print gatepass
		pack.gatepass(driver, pin2);
		out.hcs(driver);
	}
	
	
}
